package com.leeon.container.iterator;

import typeinfo.pets.Pet;
import typeinfo.pets.Pets;

import java.util.List;
import java.util.ListIterator;

public class ListIteration {

    public static void main(String[] agrs){
        List<Pet> pets = Pets.arrayList(10);
        ListIterator<Pet> it = pets.listIterator();
        while (it.hasNext()){
            System.out.println(it.next() + " . " + it.nextIndex() + " . " + it.previousIndex());
        }

        while (it.hasPrevious()){
            System.out.print(it.previous().id() + " ");
        }
        System.out.println();
        System.out.println(pets);

        it = pets.listIterator(3);
        while (it.hasNext()){
            it.next();
            it.set(Pets.randomPet());
        }

        System.out.println(pets);
     }

}
